<template>
    <div>
        用户名：<input type="text" v-model="userInfo.user">
        密码: <input type="text" v-model="userInfo.password">
        <input type="button" value="登录" @click="clickLogin">
    </div>
</template>

<script setup lang="ts">
import { reactive } from 'vue';
import {useLoginStore} from '@/stores/login';
import { useRouter } from 'vue-router';
import router from '@/router';
const loginStore = useLoginStore()

const userInfo = reactive({
    user:"",
    password:""
})

function clickLogin(){
    loginStore.login(userInfo)
    if(loginStore.loginBoolean){
        //登陆成功跳转首页
        router.push("/")
    }else{
        alert("请正确输入用户名和密码")
    }
}
</script>

<style lang="less" scoped>

</style>